﻿var page = {

    exitTimer: 0,
    loadTimer: 0,
    src: 0,

    /* 此方法在第一次显示窗体前发生 */
    onLoad: function (event) {
        this.src = "/mnt/sd0/video/" + event;
        console.dir(this.src)
        this.setData({ VideoPlayer1: { value: this.src } });
        this.videoPlayer = pm.createVideoContext("VideoPlayer1", this);
    },

    /* 此方法展示窗体后发生 */
    onResume: function (event) {

    },

    /* 当前页状态变化为显示时触发 */
    onShow: function (event) {
        var that = this;
        this.loadTimer = setTimeout(function () {
            that.videoPlayer.play();
            //clearInterval(that.loadTimer);
        }, 1 * 1000)
    },

    /* 当前页状态变化为隐藏时触发 */
    onHide: function (event) {

    },

    /* 此方法关闭窗体前发生 */
    onExit: function (event) {
        if (this.loadTimer != 0) {
            clearInterval(this.loadTimer);
        }
        if (this.exitTimer != 0) {
            clearInterval(this.exitTimer);
        }
    },

    onBack: function (event) {
        this.videoPlayer.stop()
        var that = this;
        if (this.exitTimer == 0) {
            this.exitTimer = setTimeout(function () {
                if (that.exitTimer != 0) {
                    that.exitTimer = 0;
                    pm.navigateBack({ value: { page: "VideoPage" } })
                    //clearInterval(that.exitTimer);
                }
            }, 1 * 1000);
        }
    },

};

Page(page);

page = 0;
